package com.jarvan.service.impl;

import com.jarvan.model.Admin;
import com.jarvan.repository.AdminRepository;
import com.jarvan.service.AdminService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class AdminServiceImpl implements AdminService {

    @Autowired
    private AdminRepository repository;

    @Override
    public Admin save(Admin admin) {
        return null;
    }

    @Override
    public Admin findById(Integer adminId) {
        return repository.findById(adminId).orElse(null);
    }

    @Override
    public Admin findByLoginName(String loginName) {
        return repository.findByLoginName(loginName);
    }

    @Override
    public Admin findByPhone(String phone) {
        return repository.findByPhone(phone);
    }

    @Override
    public Page<Admin> findAll(Pageable pageable) {
        return repository.findAll(pageable);
    }

    @Override
    public Page<Admin> findByStatus(Integer adminStatus, Pageable pageable) {
        return repository.findAllByAdminStatus(adminStatus, pageable);
    }
}
